package com.oak.designmode._21_single;

/**
 * @ClassName: SingleTest
 * @Description
 * @Author guoxy
 * @Date 2019/12/6 0006
 * @Version 1.0
 */
public class SingleTest {

    public static void main(String[] args){

        //饿汉模式；饿了就创建个实例
        SingletonHungry singletonHungry = SingletonHungry.getInstance();
        SingletonHungry singletonHungry1 = SingletonHungry.getInstance();
        System.out.println(singletonHungry == singletonHungry1);

        //懒汉模式：懒所以没创建实例
        SingletonLazy singletonLazy = SingletonLazy.getInstance();
        SingletonLazy singletonLazy1 = SingletonLazy.getInstance();
        System.out.println(singletonLazy == singletonLazy1);
    }
}
